package com.example.myFirstProject;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableAutoConfiguration
public class Example {
	
	@RequestMapping("/")
	String home(){
		return "hello world wanhb222222223";
	}
	
	@RequestMapping("/hello/{myName}")
	String index(@PathVariable String myName){
		return "Hello,myName:"+myName;
	}
	@RequestMapping("/test/{age}")
	String calateAgae(@PathVariable int age){
		//Integer actulAge = Integer.parseInt(age);
		String result = "";
		if (age < 10) {
			result = "小孩子";

		} else if (age > 10 && age < 18) {
			result = "青少年";
		} else {
			result = "成年人";
		}
		return result;
	}
	
	@RequestMapping(value="login",method=RequestMethod.GET)
	public String loginGet(){
		return "login page";
	}
	
	@RequestMapping(value="login",method=RequestMethod.POST)
	public String loginPost(){
		return "login page post";
	}
}
